<?php
$file_name = "data/films.txt";
$file_path = realpath($file_name);
$films = array();
$file = fopen($file_path, 'r');
while (!feof($file)) {
    $fimls[] = trim(fgets($file));
}
//var_dump($fimls);die();
fclose($file);
?>
<?php foreach ($fimls as $line): ?>
    <?php if (!empty($line)): ?>
        <?php $film = explode(";", $line); ?>
        <?php if (isset($_GET['uid'])): ?>
            <?php if ((int) $_GET['uid'] == 0): ?>
                <img src="libraries/films/<?php echo $film[1] ?>"> 
                <?php echo $film[2]; ?> <br>
            <?php else : ?>
                <?php if ((int) $_GET['uid'] == (int) $film[4]): ?>
                    <img src="libraries/films/<?php echo $film[1] ?>">
                    <?php echo $film[2]; ?>
                    <br>
                <?php endif; ?>              
            <?php endif; ?> 
        <?php endif; ?>
    <?php endif; ?>
<?php endforeach; ?>